{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Using factor analysis for decomposition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-1.33125848, -0.55846779],\n",
       "       [-1.33914102,  0.00509715],\n",
       "       [-1.40258715,  0.307983  ],\n",
       "       [-1.29839497,  0.71854288],\n",
       "       [-1.33587575, -0.36533259]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn import datasets\n",
    "iris = datasets.load_iris()\n",
    "iris_X = iris.data\n",
    "\n",
    "from sklearn.decomposition import FactorAnalysis\n",
    "\n",
    "\n",
    "\n",
    "fa = FactorAnalysis(n_components=2)\n",
    "iris_two_dim = fa.fit_transform(iris.data)\n",
    "iris_two_dim[:5]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
